Skip to content

feat(auth): add CredentialStore and cache GCP credentials#1174

Open
wolo-lab wants to merge 1 commit into
wolo/auth-gcp-providerfrom
wolo/auth-store-cache
Open

feat(auth): add CredentialStore and cache GCP credentials#1174
wolo-lab wants to merge 1 commit into
wolo/auth-gcp-providerfrom
wolo/auth-store-cache

Conversation

@wolo-lab

@wolo-lab wolo-lab commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Problem

The GCP provider (#1173) does a credential-service round-trip — plus up to a
~10s pending poll — on every request; there is no caching.

adk-python has an InMemoryCredentialService.

Summary

  • Adds auth.CredentialStore + InMemoryCredentialStore: concurrency-safe,
    with per-entry expiry and a small clock-skew margin. TokenSource-backed
    providers are self-caching and do not need it.
  • The GCP provider caches via the store (default in-memory, override with
    ProviderConfig.Store), keyed by (app, user, resource). Client.RetrieveCredential
    now returns a *Retrieval that surfaces the service's expireTime, so cache
    entries expire correctly.
  • The provider caches only when the service reports an expiry. A zero/absent
    expiry means "unknown lifetime", and caching that would risk serving a stale
    credential forever, so those results are not cached. Store writes are
    best-effort (a write failure never fails auth).
  • Resolves the acting user via agent.IdentityFromContext (from feat(auth/gcp): add GCP credential provider #1173) and keys
    the cache on id.AppName / id.UserID.

@wolo-lab
wolo-lab force-pushed the wolo/auth-store-cache branch from 995f518 to 32dc472 Compare July 18, 2026 20:44
@wolo-lab
wolo-lab force-pushed the wolo/auth-gcp-provider branch from a46455a to 421a856 Compare July 18, 2026 20:44
@wolo-lab
wolo-lab force-pushed the wolo/auth-store-cache branch from 32dc472 to d392cd9 Compare July 18, 2026 23:33
@wolo-lab
wolo-lab force-pushed the wolo/auth-gcp-provider branch from 421a856 to eadd5a6 Compare July 18, 2026 23:33
@wolo-lab
wolo-lab force-pushed the wolo/auth-store-cache branch from eb90b2c to b8ec0e5 Compare July 19, 2026 14:48
@wolo-lab
wolo-lab marked this pull request as ready for review July 19, 2026 14:58
@wolo-lab
wolo-lab requested a review from hanorik July 20, 2026 07:55
@wolo-lab
wolo-lab force-pushed the wolo/auth-gcp-provider branch 3 times, most recently from c65d414 to 9186dc4 Compare July 20, 2026 11:49
@wolo-lab
wolo-lab force-pushed the wolo/auth-store-cache branch 2 times, most recently from df296cf to 725560f Compare July 22, 2026 19:51
@wolo-lab
wolo-lab force-pushed the wolo/auth-gcp-provider branch from 9186dc4 to edeb3da Compare July 22, 2026 21:21
@wolo-lab
wolo-lab force-pushed the wolo/auth-store-cache branch 2 times, most recently from 8376298 to fe42c2e Compare July 22, 2026 21:43
Add auth.CredentialStore + InMemoryCredentialStore (concurrency-safe,
per-entry expiry with a small clock-skew margin) and cache resolved GCP
credentials in the provider, keyed by (app, user, resource). The client
surfaces the service's expireTime via a Retrieval result so entries expire
correctly; TokenSource-backed providers are self-caching and don't use it.

Resolves the acting user via agent.IdentityFromContext (rebased onto the
current auth/gcp provider).
@wolo-lab
wolo-lab force-pushed the wolo/auth-gcp-provider branch from edeb3da to a4d444d Compare July 22, 2026 22:27
@wolo-lab
wolo-lab force-pushed the wolo/auth-store-cache branch from fe42c2e to 3b151ed Compare July 22, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant